Starbucks Capstone Challenge

Introduction

This data set contains simulated data that mimics customer behavior on the Starbucks rewards mobile app. Once every few days, Starbucks sends out an offer to users of the mobile app. An offer can be merely an advertisement for a drink or an actual offer such as a discount or BOGO (buy one get one free). Some users might not receive any offer during certain weeks.

Not all users receive the same offer, and that is the challenge to solve with this data set.

Your task is to combine transaction, demographic and offer data to determine which demographic groups respond best to which offer type. This data set is a simplified version of the real Starbucks app because the underlying simulator only has one product whereas Starbucks actually sells dozens of products.

Every offer has a validity period before the offer expires. As an example, a BOGO offer might be valid for only 5 days. You'll see in the data set that informational offers have a validity period even though these ads are merely providing information about a product; for example, if an informational offer has 7 days of validity, you can assume the customer is feeling the influence of the offer for 7 days after receiving the advertisement.

You'll be given transactional data showing user purchases made on the app including the timestamp of purchase and the amount of money spent on a purchase. This transactional data also has a record for each offer that a user receives as well as a record for when a user actually views the offer. There are also records for when a user completes an offer.

Keep in mind as well that someone using the app might make a purchase through the app without having received an offer or seen an offer.

Example

To give an example, a user could receive a discount offer buy 10 dollars get 2 off on Monday. The offer is valid for 10 days from receipt. If the customer accumulates at least 10 dollars in purchases during the validity period, the customer completes the offer.

However, there are a few things to watch out for in this data set. Customers do not opt into the offers that they receive; in other words, a user can receive an offer, never actually view the offer, and still complete the offer. For example, a user might receive the "buy 10 dollars get 2 dollars off offer", but the user never opens the offer during the 10 day validity period. The customer spends 15 dollars during those ten days. There will be an offer completion record in the data set; however, the customer was not influenced by the offer because the customer never viewed the offer.

Cleaning

This makes data cleaning especially important and tricky.

You'll also want to take into account that some demographic groups will make purchases even if they don't receive an offer. From a business perspective, if a customer is going to make a 10 dollar purchase without an offer anyway, you wouldn't want to send a buy 10 dollars get 2 dollars off offer. You'll want to try to assess what a certain demographic group will buy when not receiving any offers.

Final Advice

Because this is a capstone project, you are free to analyze the data any way you see fit. For example, you could build a machine learning model that predicts how much someone will spend based on demographics and offer type. Or you could build a model that predicts whether or not someone will respond to an offer. Or, you don't need to build a machine learning model at all. You could develop a set of heuristics that determine what offer you should send to each customer (i.e., 75 percent of women customers who were 35 years old responded to offer A vs 40 percent from the same demographic to offer B, so send offer A).

Data Sets

The data is contained in three files:

Here is the schema and explanation of each variable in the files:

portfolio.json

profile.json

transcript.json

Loading dependencies

Loading the datasets

Perform the below tasks for each data set

Data Exploring

Data Cleaning

1. portfolio data

Popular offers

2. profile data

Looks like all the rows with age=118 have their income as Nan

Average age is 54-55 years

Majority of the members are between 35 - 70

Aorund 50% of members are between 42 and 66

Classify age groups as

Under 20

20-45

46-60

61-80

3. transcript data

Around 57% are Males, 41 % are Females

considering members above age 85 are outliners

Expand the keys of the 'value' column into new columns.

Data Analysis

Merge DataFrames for EDA

Most availed offers

Income distribution

Actions to the offers that customers received

Distribution of genders among age groups

Gender distribution in each offer type

Actions to the offers received

Actions to the offers received in each offer type

Actions to the offers received in each offer type

Machine Learning section

Data cleaning and & prep

Convert categorical variables such as gender, event,offer type and age groups to Numerical

Encode the 'event' data to numerical values:

offer received ---> 1

offer viewed ---> 2

offer completed ---> 3

Encode offer_id and customer_id.

Split 'became_member_on' column and create separate columns for month and year.

Scale and normalize numerical data.

train test split

Let's split the the data into train and test sets.

We will train a Machine Learning model with the train set and test the model performance on the test set

Model training and testing

We will work with few different models and decide on one model after checking their performance

We can also use an algorithm called GridSearchCV and RandomSearchCV to find the apt choice of best hyperparamets to fit our ML models. Since some of our models produce acceptable score we can stop here.

Conclusions

part - i

part - ii